package com.qf.cloud2204.feign.exhandler;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
public class GlobalExHandler {

    @ExceptionHandler(Exception.class)
    public Map<String,Object> handlEx(Exception e){
        System.out.println(e.getMessage());

        HashMap<String, Object> map = new HashMap<>();
        map.put("code",-1);
        map.put("msg","error");
        map.put("data",e.getMessage());

        return map;
    }

}
